
*************************************************
* Figure 1
*************************************************
*No data 

*************************************************
* Figure 2
*************************************************
*Constructed using the software Tableau 

*************************************************
* Figure 3
*************************************************
*Constructed using the software Tableau 

*************************************************
* Figure 4
*************************************************
use Production_well_level.dta, clear
binscatter l_total_production_realized l_total_production_p, nquantile(30) xtitle ("Predicted Production") ytitle ("Realized Production")   bgcolor(white) graphregion(fcolor(white)) ylabel(, angle(0))
reg l_total_production_realized l_total_production_p

binscatter l_total_production_realized l_production_6_month, nquantile(30) ytitle ("Realized Production")  xtitle ("First 6 months Production")   bgcolor(white) graphregion(fcolor(white)) ylabel(, angle(0))
reg l_total_production_realized l_production_6_month

*************************************************
* Figure 5
*************************************************
local shock "y_pollution d_pollution"
foreach dependent of local shock {
display "`dependent'"
eststo clear
capture postutil clear
use baseline.dta, clear
	tempname scurve
	postfile `scurve' str80 spec k1 k2 k3 k4 k5 k6 k7 main_effect post   using "baseline_direct_`dependent'.dta", replace
	local sk 1

	forvalues k1 =0(1)1 {
			if `k1'==1 local contstd_vertical "contstd_vertical"
			if `k1'==0 local contstd_vertical " "
			
		forvalues k2 =0(1)1 {
			if `k2'==1 local state_year "state_year"
			if `k2'==0 local state_year ""

        forvalues k3 =0(1)1 {
			if `k3'==1 local contstd_gas "contstd_gas"
			if `k3'==0 local contstd_gas " "

		forvalues k4 =0(1)1 {
			if `k4'==1 local contstd_horizontal "contstd_horizontal"
			if `k4'==0 local contstd_horizontal " "
			
		forvalues k5 =0(1)1 {
			if `k5'==1 local contstd_oil "contstd_oil"
			if `k5'==0 local contstd_oil " "
			
		forvalues k6 =0(1)1 {
			if `k6'==1 local confidential "confidential"
			if `k6'==0 local confidential " "
		forvalues k7 =0(1)1 {
			if `k7'==1 local FracturingDuration "FracturingDuration"
			if `k7'==0 local FracturingDuration ""


		    local spec capture reghdfe `dependent' post `FracturingDuration' `contstd_gas' `contstd_horizontal' `contstd_oil' `contstd_vertical', absorb(id_OG lat_long1_year `state_year' `confidential') vce (cluster id_OG)

			 di "`sk' k1=`k1' k2=`k2' k3=`k3' k4=`k4' k5=`k5' k6=`k6' k7=`k7' ---: `spec'  "

			 quietly: `spec'		
		local main_effect = _b[post]
			 di "`main_effect'"
		local p_main_effect = (2 * ttail(e(df_r), abs(_b[post]/_se[post])))
	
post `scurve' ("`baseline_direct_`dependent'.dta'") (`k1') (`k2') (`k3') (`k4') (`k5') (`k6') (`k7')  (`main_effect') ( `p_main_effect')

				local sk=(`sk'+1)	
			}	
			}
			}
			
	}
	}
	}
	}
	
postclose `scurve'
}


*************************************************
* Figure 6
*************************************************
local shock "y_pollution d_pollution"
foreach dependent of local shock {
display "`dependent'"
eststo clear
capture postutil clear
use baseline.dta, clear
gen post_risk=post*high_liability
	tempname scurve
	postfile `scurve' str80 spec k1 k2 k3 k4 k5 k6 k7 main_effect post_risk   using "baseline_risk_`dependent'.dta", replace
	local sk 1

	forvalues k1 =0(1)1 {
			if `k1'==1 local contstd_vertical "contstd_vertical"
			if `k1'==0 local contstd_vertical " "
			
		forvalues k2 =0(1)1 {
			if `k2'==1 local state_year "state_year"
			if `k2'==0 local state_year "high_liability"

        forvalues k3 =0(1)1 {
			if `k3'==1 local contstd_gas "contstd_gas"
			if `k3'==0 local contstd_gas " "

		forvalues k4 =0(1)1 {
			if `k4'==1 local contstd_horizontal "contstd_horizontal"
			if `k4'==0 local contstd_horizontal " "
			
		forvalues k5 =0(1)1 {
			if `k5'==1 local contstd_oil "contstd_oil"
			if `k5'==0 local contstd_oil " "
			
		forvalues k6 =0(1)1 {
			if `k6'==1 local confidential "confidential"
			if `k6'==0 local confidential " "
		forvalues k7 =0(1)1 {
			if `k7'==1 local FracturingDuration "FracturingDuration"
			if `k7'==0 local FracturingDuration ""


		    local spec capture reghdfe `dependent' post_risk `FracturingDuration' `contstd_gas' `contstd_horizontal' `contstd_oil' `contstd_vertical', absorb(id_OG_year lat_long1_year `state_year' `confidential') vce (cluster id_OG)

			 di "`sk' k1=`k1' k2=`k2' k3=`k3' k4=`k4' k5=`k5' k6=`k6' k7=`k7' ---: `spec'  "

			 quietly: `spec'		
		local main_effect = _b[post_risk]
			 di "`main_effect'"
		local p_main_effect = (2 * ttail(e(df_r), abs(_b[post_risk]/_se[post_risk])))
	
post `scurve' ("`baseline_risk_`dependent'.dta'") (`k1') (`k2') (`k3') (`k4') (`k5') (`k6') (`k7')  (`main_effect') ( `p_main_effect')

				local sk=(`sk'+1)	
			}	
			}
			}
			
	}
	}
	}
	}
	
postclose `scurve'
}


*************************************************
* Figure 7
*************************************************
local shock "y_pollution d_pollution"
foreach dependent of local shock {
display "`dependent'"
eststo clear
capture postutil clear
use baseline.dta, clear
gen effect=d_sensible*y2017*post

	tempname scurve
	postfile `scurve' str80 spec k1 k2 k3 k4 k5 k6 k7 main_effect effect   using "nat_year_`dependent'.dta", replace
	local sk 1

	forvalues k1 =0(1)1 {
			if `k1'==1 local contstd_vertical "contstd_vertical"
			if `k1'==0 local contstd_vertical " "
			
		forvalues k2 =0(1)1 {
			if `k2'==1 local state_year "state_year"
			if `k2'==0 local state_year ""

        forvalues k3 =0(1)1 {
			if `k3'==1 local contstd_gas "contstd_gas"
			if `k3'==0 local contstd_gas " "

		forvalues k4 =0(1)1 {
			if `k4'==1 local contstd_horizontal "contstd_horizontal"
			if `k4'==0 local contstd_horizontal " "
			
		forvalues k5 =0(1)1 {
			if `k5'==1 local contstd_oil "contstd_oil"
			if `k5'==0 local contstd_oil " "
			
		forvalues k6 =0(1)1 {
			if `k6'==1 local confidential "confidential"
			if `k6'==0 local confidential " "
		forvalues k7 =0(1)1 {
			if `k7'==1 local FracturingDuration "FracturingDuration"
			if `k7'==0 local FracturingDuration ""

*y2017, post, and c.post#c.y2017 are absorbed by id_OG_year
		    local spec capture reghdfe `dependent' effect d_sensible c.d_sensible#c.post c.d_sensible#c.y2017 `FracturingDuration' `contstd_gas' `contstd_horizontal' `contstd_oil' `contstd_vertical', absorb(id_OG_year lat_long1_year `state_year' `confidential') vce (cluster id_OG)
			 di "`sk' k1=`k1' k2=`k2' k3=`k3' k4=`k4' k5=`k5' k6=`k6' k7=`k7' ---: `spec'  "

			 quietly: `spec'		
		local main_effect = _b[effect]
			 di "`main_effect'"
		local p_main_effect = (2 * ttail(e(df_r), abs(_b[effect]/_se[effect])))
	
post `scurve' ("`nat_year_`dependent'.dta'") (`k1') (`k2') (`k3') (`k4') (`k5') (`k6') (`k7')  (`main_effect') ( `p_main_effect')

				local sk=(`sk'+1)	
			}	
			}
			}
			
	}
	}
	}
	}
	
postclose `scurve'
}

*************************************************
* Figure 8
*************************************************
use baseline.dta, clear

*Spec 1:
reghdfe d_pollution d_sensible PE_target post c.PE_target#c.d_sensible pp_2012 pp_2013 pp_2015 pp_2016 pp_2017 pp_2018  pp_2019 pp_2020 pp_2021 contstd_*, absorb(lat_long1 id_OG year) vce (cluster id_OG)

*Spec 2:
reghdfe d_pollution d_sensible PE_target post c.PE_target#c.d_sensible pp_2012 pp_2013 pp_2015 pp_2016 pp_2017 pp_2018 pp_2019 pp_2020 pp_2021 contstd_*, absorb(cst) vce (cluster id_OG)

*Spec 3:
reghdfe d_pollution d_sensible PE_target post c.PE_target#c.d_sensible pp_2012 pp_2013 pp_2015 pp_2016 pp_2017 pp_2018 pp_2019 pp_2020 pp_2021 contstd_*, absorb(lat_long1 id_OG) vce (cluster id_OG)
